/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tests.subtask2;

import task.Official;
import task.Board;
import solution.BoardFactory;
import task.Official.Color;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

/**
 *
 * @author florian
 */
public class PublicMoveTest {

    public PublicMoveTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    @Test(timeout = 1000)
    public void testMovingToWall() {
        Board board = BoardFactory.newBoard(3, 3);
        board.addWallEast(1, 0);

        Official official = board.addOfficial(0, 0, Color.Black, Color.Black);
        official.moveEast();

        assertEquals(official, board.getOfficial(1, 0));
    }

    @Test(timeout = 1000)
    public void testMovingToPerimeterWall() {
        // move towards a wall on the edge of the board
        Board board = BoardFactory.newBoard(3, 3);
        board.addWallWest(0, 0);
        Official official = board.addOfficial(0, 0, Color.Black, Color.Black);
        official.moveWest();

        assertEquals(official, board.getOfficial(0, 0));
    }

    @Test(timeout = 1000)
    public void testMovingToBlock() {
        Board board = BoardFactory.newBoard(3, 3);
        board.addBlock(0, 2);

        Official official = board.addOfficial(0, 0, Color.Black, Color.Black);
        official.moveNorth();

        assertEquals(official, board.getOfficial(0, 1));
    }

    @Test(timeout = 1000)
    public void testMovingToOfficial() {
        Board board = BoardFactory.newBoard(3, 3);
        board.addOfficial(0, 0, Color.Blue, Color.Green);

        Official official = board.addOfficial(0, 2, Color.Black, Color.Black);
        official.moveSouth();

        assertEquals(official, board.getOfficial(0, 1));
    }

    @Test(timeout = 1000)
    public void testMovingTwiceToWall() {
        // maybe the wall gets penetrated the second time we move there?
        Board board = BoardFactory.newBoard(3, 3);
        board.addWallEast(1, 0);

        Official official = board.addOfficial(0, 0, Color.Black, Color.Black);
        official.moveEast();
        official.moveEast();

        assertEquals(official, board.getOfficial(1, 0));
    }
}
